package com.zyh.map;

import java.util.Set;
import java.util.TreeMap;

/**
 * @Author zyh
 * @Date 2024/8/2 11:05
 * @Description TreeMap 常用类型排序
 */

public class TreeMapDemo1 {
    public static void main(String[] args) {
        TreeMap<Integer, String> map = new TreeMap<>();
        map.put(2,"q");
        map.put(5,"s");
        map.put(1,"g");
        map.put(3,"h");
        map.put(4,"p");
        Set<Integer> keySet = map.keySet();
        for (Integer key : keySet) {
            String value = map.get(key);
            System.out.println(key+"--"+value);
        }
        /*Set<Map.Entry<Integer, String>> entries = map.entrySet();
        for (Map.Entry<Integer, String> entry : entries) {
            System.out.println(entry.getKey()+"---"+entry.getValue());
        }*/
    }
}
